<?php

namespace App\Http\Resources;

use App\Models\Account;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Http\Resources\Json\JsonResource;


/** @mixin Account * */
class AccountResource extends JsonResource
{
    public function toArray($request): array
    {
        $data = parent::toArray($request);
        $data['created_at'] = Carbon::parse($data['created_at'])->timestamp;

        if (!isset($data['type_str']) || empty($data['type_str'])){
            $data['type_str'] = trans('validation.account_type')[$this->resource->type];
        }
        return $data;
    }
}
